package com.tang.algorithm.greedy;

/**
 * @author tlm
 * @version 1.0
 * @date 2020/6/25 18:01
 */
public class LeetCode1221 {
    public static void main(String[] args) {

    }
    public int balancedStringSplit(String s) {
        //贪心算法
        int res = 0;
        int num = 0;
        for (int i = 0; i <s.length() ; i++) {
            if(s.charAt(i)=='L'){
                num++;
            }else {
                num--;
            }
            if(num==0){
                res++;
            }
        }
        return res;
    }
}
